import Field from 'winged/utils/wt-model-field'

export default {
	title: '出院记录',
	name: 'discharge',
	tableName: 'discharge',
	single: true,
	query: {
		method: 'GET',
		url: 'doctor/patient/discharge',
		transfer: true,
		placeholder: '当前没有出院记录',
		extraParams: [
			'case_id',
		]
	},
	new: {
		method: 'POST',
		url: 'doctor/patient/discharge',
		transfer: true,
		extraParams: [
			'case_id',
		]
	},
	update: {
		method: 'PUT',
		url: 'doctor/patient/discharge',
		transfer: true
	},
	delete: {
		method: 'DELETE',
		url: 'doctor/patient/discharge',
		transfer: true
	},
	id_field: {
		name: 'discharge_id',
	},
	fields: [
		{
		label: '出院时间',
		type: Field.types.date,
		display: true,
		name: 'discharge_date',
		tableName: 'dischargeDate',
		customComponent: 'wt-case-discharge-date',
		rules: [
			{ type: 'date', required: true, message: '请选择出院时间', trigger: 'blur' }
		]
	},{
			label: '住院天数',
			type: Field.types.number,
			display: true,
			summary: true,
			readonly: true,
			name: 'discharge_day',
			tableName: 'hospitalDay',
			formSize: 'mini',
			appendComponent: 'wt-case-discharge-days',
			dependingField:{
				name: 'dischargeDate',
				message: '请先选择出院时间',
			},
			rules: [
				{ type: 'number', required: true, message: '请计算住院天数', },
				{ type: 'number', min:0, trigger:'blur', required: true, message: '请填写正确的出院时间',}
				]
		}, {
			label: '费用',
			type: Field.types.number,
			unit: '元',
			display: true,
			summary: true,
			name: 'discharge_fee',
			formSize: 'small',
			tableName: 'hosptalFeeYuan',
			rules: [
				{ type: 'number', required: true, message: '请输入住院费用', trigger: 'change' },
				{ type: 'number', message: '请输入数字'},
				{ type: 'number', min:0, trigger:'blur', message: '请输入大于零的数字'}
				]
		}, {
			label: '出院带药',
			type: Field.types.textarea,
			display: true,
			name: 'medicine_home',
			tableName: 'medicineHome'
		},{
			label: '备注',
			type: Field.types.textarea,
			display: true,
			name: 'comment',
			tableName: 'comment'
		},{
			label: '图片',
			type: Field.types.images,
			display: true,
			summary: true,
			name: 'image_urls',
			tableName: 'dischargeImages',
			uploadByComponent: true,
			saveAsJson: true,
			preSubmit: true,
		}, 
	]
};